Skip to content

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Feb 19, 2025

The Matrix spec allows anything in the device ID.
With MAS and MSC3861, we restricted that to anything that can be represented as a scope.
But this is valid for next-gen auth sessions, not necessarily for compatibility ones.

Slight problem is, for compatibility sessions, we're still giving out the device ID as a scope to Synapse, so that won't fly with a device ID that can't be represented that way.

To sidestep this, we now return the device ID as an explicit property in the introspection response.
This means the homeserver still has to adapt to this behaviour, so we can't just remove the device ID from the scope.

This is why we're introducing a header to the introspectio endpoint which lets the homeserver advertise its support for this behaviour.

Fixes #2724
Fixes #4027

Synapse PR: element-hq/synapse#18174

Copy link

cloudflare-workers-and-pages bot commented Feb 19, 2025

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7c9bb73
Status: ✅  Deploy successful!
Preview URL: https://5e4ecd91.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://quenting-compat-device-id.matrix-authentication-service-docs.pages.dev

View logs

@sandhose sandhose marked this pull request as ready for review February 20, 2025 09:28
@sandhose sandhose mentioned this pull request Feb 24, 2025
@sandhose sandhose requested a review from reivilibre March 3, 2025 18:02
@sandhose sandhose added A-Compatibility-Layer Related to the legacy Matrix authentication compatibility layer T-Defect Something isn't working labels Mar 4, 2025
@sandhose sandhose merged commit 96b4d5f into main Mar 4, 2025
21 checks passed
@sandhose sandhose deleted the quenting/compat-device-id branch March 4, 2025 12:42
reivilibre pushed a commit to element-hq/synapse that referenced this pull request Mar 4, 2025
The context for this is that the Matrix spec allows basically anything
in the device ID. With MSC3861, we're restricting this to strings that
can be represented as scopes.
Whilst this works well for next-gen auth sessions, compatibility/legacy
sessions still can have characters that can't be encoded (mainly spaces)
in them.

To work around that, we added in MAS a behaviour where the device_id is
given as an explicit property of the token introspection response, and
remove it from the scope.
Because we don't expect users to rollout new Synapse and MAS versions in
sync, we needed a way to 'advertise' support for this behaviour: the
easiest way to do that was through an extra header in the introspection
response.

On the longer term, I expect MAS and Synapse to move away from the
introspection endpoint, and instead define a specific API for Synapse ->
MAS communication.

PR on the MAS side:
element-hq/matrix-authentication-service#4067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Compatibility-Layer Related to the legacy Matrix authentication compatibility layer T-Defect Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete session bug Database inconsistency from some device IDs

2 participants